package pub.guoxin.server.simulation.service.impl;

import org.assertj.core.util.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pub.guoxin.oops.constants.TopicName;
import pub.guoxin.oops.model.Communication;
import pub.guoxin.oops.model.CommunicationData;
import pub.guoxin.oops.model.DeviceDataInfo;
import pub.guoxin.oops.msg.MessageDataProducer;
import pub.guoxin.server.simulation.service.Sender;

import java.util.List;

/**
 * Create by guoxin on 2018/5/12
 */
@Service("messageQueueSender")
public class MessageQueueSender implements Sender {

    @Autowired
    private MessageDataProducer messageDataProducer;

    @Override
    public void send(String message) {
        Communication communication = new Communication();
        DeviceDataInfo deviceDataInfo =  new DeviceDataInfo();
        List<DeviceDataInfo> devices = Lists.newArrayList();
        CommunicationData build = CommunicationData.builder().communication(communication).deviceDataInfos(devices).build();
        messageDataProducer.sender(TopicName.DATA_ALARM_TOPIC, build);
    }
}
